package com.liohi.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.liohi.entity.UserRole;
import com.liohi.service.UserRoleService;
import com.liohi.mapper.UserRoleMapper;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
* @author liohi
* @description 针对表【user_role】的数据库操作Service实现
* @createDate 2023-08-02 15:10:31
*/
@Service
public class UserRoleServiceImpl extends ServiceImpl<UserRoleMapper, UserRole>
    implements UserRoleService{

    @Override
    public List<Integer> getRoleIdsByUserId(Integer userId) {

        List<Integer> res = new ArrayList<>();
        List<UserRole> userRoles = baseMapper.selectList(new QueryWrapper<UserRole>().eq("user_id", userId));
        for(UserRole userRole: userRoles){
            res.add(userRole.getRoleId());
        }
        return res;
    }
}




